﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace information
{
    public partial class DeleteData : Form
    {
        public DeleteData()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            string strcon;
            strcon = "Server=192.168.0.88; Database=information;User id ='sa';pwd=123456";  //information            
            SqlConnection myon = new SqlConnection(strcon);
            myon.Open();
            MessageBox.Show("数据库连接成功", "数据库");
            if (textBox1.Text.Length == 0)
            {
                MessageBox.Show("ID无输入");
                textBox1.Focus();
            }
            else
            {
                int id = Convert.ToInt32(textBox1.Text);
                try
                {
                    SqlCommand sqlcom = new SqlCommand("delete from InformationTable where id=" + id, myon);
                    sqlcom.ExecuteNonQuery();
                    MessageBox.Show("删除成功！", "啊");
                    myon.Close();
                }
                catch (Exception a)
                {
                    MessageBox.Show(a.ToString());
                }
            }
        }
    }
}